#ifndef VECTOR_H
#define VECTOR_H

/* a vector of real numbers */


typedef struct vector
{
  /* clients should only modify the following field and nothing else */
  double * pelems_vector;


  int numelem_vector;                        /* number of used elements */
  int numalloc_vector;                       /* number of allocated elements */

} vector;

#define VECTOR_IDX(vec, i) ((vec)->pelems_vector[(i)])
#define VECTOR_LEN(vec) ((vec)->numelem_vector)

vector * vector_alloc(int numalloc);         /* allocate a vector */
void vector_free(vector * vec);              /* free a vector */
void vector_append(vector * vec, double val); /* append an element to vector */
double vector_sum(vector * vec);  /* add the elements of the vector */

#endif /* VECTOR_H */
  
